package com.umakr.demo.controller;

import com.umakr.demo.model.Banji;
import com.umakr.demo.service.BanjiSerivice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by yangliu on 2017/8/18.
 */
@Controller
@RequestMapping("/BanjiController")
public class BanjiController {

    @Autowired
    BanjiSerivice banjiSerivice;

    @RequestMapping("/showBanji")
    public String showBanji(){
        return "StudentManage/banji";
    }

    @RequestMapping("/banjiData")
    @ResponseBody
    public List banjiData(){
        return banjiSerivice.showAll();
    }

    @RequestMapping("/updataBanji")
    @ResponseBody
    public List updataBanji(Long bid,String bname){
        Banji banji = new Banji(bid,bname);
        banjiSerivice.updataBanji(banji);
        List<Banji> list = banjiSerivice.showAll();
        return list;
    }
    @RequestMapping("/deleteBanji")
    @ResponseBody
    public List deleteBanji(Long bid,String bname){
        Banji banji = new Banji(bid,bname);
        banjiSerivice.deleteBanji(banji);
        List<Banji> list = banjiSerivice.showAll();
        return list;
    }


    @RequestMapping("/saveBanji")
    @ResponseBody
    public List saveBanji(Long bid,String bname){
        Banji banji = new Banji(bid,bname);
        System.out.println(banji.toString());
        banjiSerivice.saveBanji(banji);
        List<Banji> list = banjiSerivice.showAll();
        return list;
    }



}
